<template>
  <div>
    <ul>
      <li v-for="item in list" :key="item.id">
        <img :src="item.img" alt="" style="width: 200px" />
        {{ item.title }}
      </li>
    </ul>
    <div v-ww></div>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  name: '',
  directives: {
    'ww': {
      inserted (el, ss) {
        el.classList.add('active')
        el.innerHTML = '加载中......'
      },
      update (el, ss) {
        setTimeout(function () {
          el.classList.remove('active')
          el.innerHTML = ''
        }, 3000)
      }
    }
  },
  data () {
    return {
      list: []
    }
  },
  mounted () {

  },
  created () {
    this.fn()
  },
  computed: {
  },
  methods: {
    async fn () {
      const res = await axios.get('http://hmajax.itheima.net/api/news')
      console.log(res.data.data);
      this.list = res.data.data
    }
  }
}
</script>
<style lang='less'  scoped>
.active {
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  position: fixed;
  left: 0;
  top: 0;
  text-align: center;
  line-height: 100vh;
}
</style>
